package com.example.netlib;

import android.util.Log;
import android.view.View;

import com.szlanyou.thirdsdk.retrofit.callback.ClickViewRelatedHttpResultHandler;
import com.szlanyou.thirdsdk.retrofit.callback.IHttpResultHandler;

/**
 * @author 陈章
 * create at 2021/7/8 16:04
 * desc:统一处理结果进行打印
 */
public class DefaultHttpResultHandler<T> extends ClickViewRelatedHttpResultHandler<T> {
    private static final String TAG = "DefaultHttpResultHandle";

    public DefaultHttpResultHandler(View clickView) {
        super(clickView);
    }

    public DefaultHttpResultHandler() {
    }

    @Override
    public void onStart(String requestPageFlag,String requestCode) {
        super.onStart(requestPageFlag, requestCode);
        Log.d(TAG, "onStart: requestCode = " + requestCode);
    }

    @Override
    public void onSuccess(String requestPageFlag,String requestCode, T successBean) {
        Log.d(TAG, "onSuccess: requestCode = " + requestCode + ",successBean = " + successBean);
    }

    @Override
    public void onError(String requestPageFlag,String requestCode, Throwable e) {
        Log.e(TAG, "onError: requestCode = " + requestCode);
        e.printStackTrace();
    }

    @Override
    public void onFailure(String requestPageFlag,String requestCode, String responseCode, String msg) {
        Log.e(TAG, "onFailure: requestCode = " + requestCode + ",responseCode = " + responseCode + ",msg = " + msg);
    }

    @Override
    public void onCancel(String requestPageFlag,String requestCode) {
        super.onCancel(requestPageFlag, requestCode);
        Log.d(TAG, "onCancel: requestCode = " + requestCode);
    }

    @Override
    public void onComplete(boolean causeByError) {
        super.onComplete(causeByError);
        Log.d(TAG, "onComplete: ");
    }
}
